package com.woniuxy.controller;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.woniuxy.entity.RbacManager;
import com.woniuxy.entity.RbacRole;
import com.woniuxy.entity.ResponseEntity;
import com.woniuxy.servcie.RbacRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 佘赛飞
 * @create 2021-11-26 9:34 下午
 */
@RestController
public class RbacRoleController {
    @Autowired
    RbacRoleService rbacRoleService;

    @GetMapping("/findOneRbacRole/{id}")
    public RbacRole findOneRbacRole(@PathVariable int id){
        return rbacRoleService.findOneRbacRole(id);
    }
    @RequestMapping("/findAllRbacRole")
    public List <RbacRole> findAllRbacRole(@RequestBody RbacManager rbacManager){
        return rbacRoleService.findAllRbacRole(rbacManager);
    }
    @RequestMapping("/addRbacRole")
    public void addRbacRole(@RequestBody RbacRole rbacRole){
        rbacRoleService.addRbacRole(rbacRole);
    }

    @RequestMapping("/upRbacRole")
    public Integer UpRbacRole(@RequestBody RbacRole rbacRole){
        return rbacRoleService.UpRbacRole(rbacRole);
    }

    @RequestMapping("/deleteRbacRole")
    public void deleteRbacRole(@RequestBody RbacRole rbacRole){
        rbacRoleService.deleteRbacRole(rbacRole);
    }
    @GetMapping("/FindAllAndPaginationRbacRole/{startPage}/{pageSize}")
    public PageInfo<RbacRole>FindAllAndPaginationRbacRole(@PathVariable("startPage") int startPage
            ,@PathVariable("pageSize") int pageSize){

        PageHelper.startPage(startPage,pageSize);
        List <RbacRole> rbacRoles = rbacRoleService.FindAllAndPaginationRbacRole();
        PageInfo<RbacRole> rbacRolePageInfo = new PageInfo<>(rbacRoles);
        return rbacRolePageInfo;
    }
    @GetMapping("/findAllResRbacRole/{startPage}/{pageSize}")
    public ResponseEntity<PageInfo<RbacRole>> findAllResRbacRole(@PathVariable("startPage") int startPage
            , @PathVariable("pageSize") int pageSize){
        PageHelper.startPage(startPage,pageSize);
        List <RbacRole> rbacRoles = rbacRoleService.FindAllAndPaginationRbacRole();
        PageInfo<RbacRole> rbacRolePageInfo = new PageInfo<>(rbacRoles);
        return new ResponseEntity(200,"查询成功",rbacRolePageInfo);
    }
}
